<?php
$this->breadcrumbs=array(
	'Products'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List Product', 'url'=>array('index')),
	array('label'=>'Create Product', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('product-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Products</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
    'time' =>$time
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'product-grid',
	'dataProvider'=>$model->search($time),
	'filter'=>$model,
	'columns'=>array(
		'id',
//		array(
//            'name'=>'category_id',
//            'filter'=>Category::listCategory(),
//            'value'=>'Category::model()->findByPk($data->category_id)->name'
//        ),
		'name',
            'description',
//		array(
//            'name' => 'status',
//            'filter' => array(1 => 'enable', 0 => 'disable'),
//            'value'  => '($data->status == 1 ? "Enable" : "Disable")'
//        ),
//		array(
//            'name'=>'tax_id',
//            'value'=>'Tax::model()->findByPk($data->tax_id)->percent'
//        ),
        array(
            'name'  => 'created_time',
            'value' => 'date("d/m/Y", $data->created_time)',
            'filter'=> false
        ),

		array(
			'class'=>'CButtonColumn', 
			'template' => '{view}{update}{delete}{images}',
			'viewButtonUrl' => 'Yii::app()->createUrl("/admin/product/view",
			array("id" => $data->id))',
			'updateButtonUrl' => 'Yii::app()->createUrl("/admin/product/update",
			array("id" => $data->id))',
			'deleteButtonUrl' => 'Yii::app()->createUrl("/admin/product/delete",
			array("id" => $data->id))',
			'buttons' => array(
				'images' => array(
					//'label' => 'images',
                                        'imageUrl'=>Yii::app()->request->baseUrl.'/images/fff/image_add.png',
					'url' => 'Yii::app()->createUrl("/admin/image/admin",
					array("product_id" => $data->id))',
				),
			),
		),
	),
)); ?>
